# Maintainer: umarcor <unai.martinezcorral@ehu.eus>

_realname=serial-studio
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.0.21
pkgrel=1
pkgdesc="Serial Studio: Multi-purpose serial data visualization & processing program (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/Serial-Studio/Serial-Studio"
license=('MIT')
groups=("${MINGW_PACKAGE_PREFIX}-eda")
depends=("${MINGW_PACKAGE_PREFIX}-qt5-declarative"
         "${MINGW_PACKAGE_PREFIX}-qt5-svg"
         "${MINGW_PACKAGE_PREFIX}-qt5-charts"
         "${MINGW_PACKAGE_PREFIX}-qt5-serialport"
         "${MINGW_PACKAGE_PREFIX}-qt5-quickcontrols2"
         "${MINGW_PACKAGE_PREFIX}-qt5-graphicaleffects")
makedepends=(
  'git'
  "${MINGW_PACKAGE_PREFIX}-gcc"
  "${MINGW_PACKAGE_PREFIX}-cmake"
  "${MINGW_PACKAGE_PREFIX}-qt5-tools"
)

source=("${_realname}::git+https://github.com/${_realname}/${_realname}#commit=v${pkgver}")
sha256sums=('SKIP')

prepare() {
  cd "${srcdir}/${_realname}"
  git submodule update --init --recursive
}

build() {
  [[ -d "${srcdir}/build-${MSYSTEM}" ]] && rm -rf "${srcdir}/build-${MSYSTEM}"
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="PREFIX=" \
  qmake PREFIX="${MINGW_PREFIX}" ../${_realname}

  MSYS2_ARG_CONV_EXCL="--resource-file-mapping=" \
  make
}

check() {
  ${srcdir}/build-${MSYSTEM}/release/Serial-Studio.exe --help
}

package() {
  cd ${srcdir}/build-${MSYSTEM}
  make INSTALL_ROOT="${pkgdir}" install
}
